Imports System.Windows.Forms
Imports Dao
Imports System.Data
Imports DTO
Public Class QUYENCHITIETBus
    Inherits AbstractBus
    Public Sub New()
    End Sub
    Public Sub New(ByVal ConnectionString As KetNoiDto)
        ketnoi = ConnectionString
    End Sub
#Region "Xử Lý"
    Public Sub Them(ByVal Dto As QUYENCHITIETdto)
        Dim Dao As New QUYENCHITIETDao(ketnoi)
        Dao.Them(Dto)
    End Sub
    Public Sub Xoa(ByVal iD As System.Int32)
        Dim Dao As New QUYENCHITIETDao(ketnoi)
        Dao.Xoa(iD)
    End Sub
    Public Sub sua(ByVal Dto As QUYENCHITIETdto)
        Dim Dao As New QUYENCHITIETDao(ketnoi)
        Dao.sua(Dto)
    End Sub
#End Region
    Public Function LayBangTable() As DataTable
        Dim Dao As New QUYENCHITIETDao(ketnoi)
        Dao.layBang()
        Return Dao
    End Function
    Public Function LayBangTableIlist() As IList
        Dim Dao As New QUYENCHITIETDao(ketnoi)
        Dim aList As New ArrayList
        For i As Integer = 0 To Dao.Rows.Count - 1
            Dim dtoQUYENCHITIET As QUYENCHITIETdto = LayBangDTo(i, Dao)
            aList.Add(dtoQUYENCHITIET)
        Next
        Return aList
    End Function
    Public Function LayBangTableSQL(ByVal sql As String) As DataTable
        Dim Dao As New AbstractDao(sql, sql, ketnoi)
        Return Dao
    End Function
    Public Sub suaQuyen(ByVal Quyen As System.Int32, ByVal iD As System.Int32)
        Dim dao As New QUYENCHITIETDao(ketnoi)
        dao.SuaQuyen(Quyen, iD)
    End Sub
    Public Sub suaTenForm(ByVal TenForm As System.String, ByVal iD As System.Int32)
        Dim dao As New QUYENCHITIETDao(ketnoi)
        dao.SuaTenForm(TenForm, iD)
    End Sub
    Public Sub suaTenButon(ByVal TenButon As System.String, ByVal iD As System.Int32)
        Dim dao As New QUYENCHITIETDao(ketnoi)
        dao.SuaTenButon(TenButon, iD)
    End Sub
    Public Sub suaTrangthai(ByVal Trangthai As System.Int32, ByVal iD As System.Int32)
        Dim dao As New QUYENCHITIETDao(ketnoi)
        dao.SuaTrangthai(Trangthai, iD)
    End Sub
    Public Sub suaGhichu(ByVal Ghichu As System.String, ByVal iD As System.Int32)
        Dim dao As New QUYENCHITIETDao(ketnoi)
        dao.SuaGhichu(Ghichu, iD)
    End Sub
    Public Function LayBangTable(ByVal iD As System.Int32) As DataTable
        Dim Dao As New QUYENCHITIETDao(iD, ketnoi)
        Return Dao
    End Function
    Public Function LayBangTableIlist(ByVal iD As System.Int32) As IList
        Dim Dao As New QUYENCHITIETDao(iD, ketnoi)
        Dim aList As New ArrayList
        For i As Integer = 0 To Dao.Rows.Count - 1
            Dim dtoQUYENCHITIET As QUYENCHITIETdto = LayBangDTo(i, Dao)
            aList.Add(dtoQUYENCHITIET)
        Next
        Return aList
    End Function
    Public Function LayBangTableTheoiD(ByVal iD As System.Int32) As DataTable
        Dim Dao As New QUYENCHITIETDao(ketnoi)
        Dao.layBangTheoiD(iD)
        Return Dao
    End Function
    Public Function LayBangTableTheoiD(ByVal ARRAY1 As ArrayList) As DataTable
        Dim Dao As New QUYENCHITIETDao(ketnoi)
        Dao.layBangTheoiD(ARRAY1)
        Return Dao
    End Function
    Public Sub XOAbangTableTheoiD(ByVal iD As System.Int32)
        Dim Dao As New QUYENCHITIETDao(ketnoi)
        Dao.XOABangTheoiD(iD)
    End Sub
    Public Function LayBangTableTheoQuyen(ByVal Quyen As System.Int32) As DataTable
        Dim Dao As New QUYENCHITIETDao(ketnoi)
        Dao.layBangTheoQuyen(Quyen)
        Return Dao
    End Function
    Public Function LayBangTableTheoQuyen(ByVal ARRAY1 As ArrayList) As DataTable
        Dim Dao As New QUYENCHITIETDao(ketnoi)
        Dao.layBangTheoQuyen(ARRAY1)
        Return Dao
    End Function
    Public Sub XOAbangTableTheoQuyen(ByVal Quyen As System.Int32)
        Dim Dao As New QUYENCHITIETDao(ketnoi)
        Dao.XOABangTheoQuyen(Quyen)
    End Sub
    Public Function LayBangTableTheoTenForm(ByVal TenForm As System.String) As DataTable
        Dim Dao As New QUYENCHITIETDao(ketnoi)
        Dao.layBangTheoTenForm(TenForm)
        Return Dao
    End Function
    Public Function LayBangTableTheoTenForm_like(ByVal TenForm As System.String) As DataTable
        Dim Dao As New QUYENCHITIETDao(ketnoi)
        Dao.layBangTheoTenForm_like(TenForm)
        Return Dao
    End Function
    Public Function LayBangTableTheoTenForm(ByVal ARRAY1 As ArrayList) As DataTable
        Dim Dao As New QUYENCHITIETDao(ketnoi)
        Dao.layBangTheoTenForm(ARRAY1)
        Return Dao
    End Function
    Public Sub XOAbangTableTheoTenForm(ByVal TenForm As System.String)
        Dim Dao As New QUYENCHITIETDao(ketnoi)
        Dao.XOABangTheoTenForm(TenForm)
    End Sub
    Public Function LayBangTableTheoTenButon(ByVal TenButon As System.String) As DataTable
        Dim Dao As New QUYENCHITIETDao(ketnoi)
        Dao.layBangTheoTenButon(TenButon)
        Return Dao
    End Function
    Public Function LayBangTableTheoTenButon_like(ByVal TenButon As System.String) As DataTable
        Dim Dao As New QUYENCHITIETDao(ketnoi)
        Dao.layBangTheoTenButon_like(TenButon)
        Return Dao
    End Function
    Public Function LayBangTableTheoTenButon(ByVal ARRAY1 As ArrayList) As DataTable
        Dim Dao As New QUYENCHITIETDao(ketnoi)
        Dao.layBangTheoTenButon(ARRAY1)
        Return Dao
    End Function
    Public Sub XOAbangTableTheoTenButon(ByVal TenButon As System.String)
        Dim Dao As New QUYENCHITIETDao(ketnoi)
        Dao.XOABangTheoTenButon(TenButon)
    End Sub
    Public Function LayBangTableTheoTrangthai(ByVal Trangthai As System.Int32) As DataTable
        Dim Dao As New QUYENCHITIETDao(ketnoi)
        Dao.layBangTheoTrangthai(Trangthai)
        Return Dao
    End Function
    Public Function LayBangTableTheoTrangthai(ByVal ARRAY1 As ArrayList) As DataTable
        Dim Dao As New QUYENCHITIETDao(ketnoi)
        Dao.layBangTheoTrangthai(ARRAY1)
        Return Dao
    End Function
    Public Sub XOAbangTableTheoTrangthai(ByVal Trangthai As System.Int32)
        Dim Dao As New QUYENCHITIETDao(ketnoi)
        Dao.XOABangTheoTrangthai(Trangthai)
    End Sub
    Public Function LayBangTableTheoGhichu(ByVal Ghichu As System.String) As DataTable
        Dim Dao As New QUYENCHITIETDao(ketnoi)
        Dao.layBangTheoGhichu(Ghichu)
        Return Dao
    End Function
    Public Function LayBangTableTheoGhichu_like(ByVal Ghichu As System.String) As DataTable
        Dim Dao As New QUYENCHITIETDao(ketnoi)
        Dao.layBangTheoGhichu_like(Ghichu)
        Return Dao
    End Function
    Public Function LayBangTableTheoGhichu(ByVal ARRAY1 As ArrayList) As DataTable
        Dim Dao As New QUYENCHITIETDao(ketnoi)
        Dao.layBangTheoGhichu(ARRAY1)
        Return Dao
    End Function
    Public Sub XOAbangTableTheoGhichu(ByVal Ghichu As System.String)
        Dim Dao As New QUYENCHITIETDao(ketnoi)
        Dao.XOABangTheoGhichu(Ghichu)
    End Sub
    Public Function LayBangDTo(ByVal iD As System.Int32) As QUYENCHITIETdto
        Dim Dao As New QUYENCHITIETDao(iD, ketnoi)
        Dim dto As New QUYENCHITIETdto
        If Dao.Rows.Count <= 0 Then Return dto
        Try
            If IsDBNull(Dao.Rows(0)("iD")) = False Then
                dto.iD = Dao.Rows(0)("iD")
            End If
        Catch ex As Exception
        End Try
        Try
            If IsDBNull(Dao.Rows(0)("QUYENCHITIET.iD")) = False Then
                dto.iD = Dao.Rows(0)("QUYENCHITIET.iD")
            End If
        Catch ex As Exception
        End Try
        Try
            If IsDBNull(Dao.Rows(0)("Quyen")) = False Then
                dto.Quyen = Dao.Rows(0)("Quyen")
            End If
        Catch ex As Exception
        End Try
        Try
            If IsDBNull(Dao.Rows(0)("QUYENCHITIET.Quyen")) = False Then
                dto.Quyen = Dao.Rows(0)("QUYENCHITIET.Quyen")
            End If
        Catch ex As Exception
        End Try
        Try
            If IsDBNull(Dao.Rows(0)("TenForm")) = False Then
                dto.TenForm = Dao.Rows(0)("TenForm")
            End If
        Catch ex As Exception
        End Try
        Try
            If IsDBNull(Dao.Rows(0)("QUYENCHITIET.TenForm")) = False Then
                dto.TenForm = Dao.Rows(0)("QUYENCHITIET.TenForm")
            End If
        Catch ex As Exception
        End Try
        Try
            If IsDBNull(Dao.Rows(0)("TenButon")) = False Then
                dto.TenButon = Dao.Rows(0)("TenButon")
            End If
        Catch ex As Exception
        End Try
        Try
            If IsDBNull(Dao.Rows(0)("QUYENCHITIET.TenButon")) = False Then
                dto.TenButon = Dao.Rows(0)("QUYENCHITIET.TenButon")
            End If
        Catch ex As Exception
        End Try
        Try
            If IsDBNull(Dao.Rows(0)("Trangthai")) = False Then
                dto.Trangthai = Dao.Rows(0)("Trangthai")
            End If
        Catch ex As Exception
        End Try
        Try
            If IsDBNull(Dao.Rows(0)("QUYENCHITIET.Trangthai")) = False Then
                dto.Trangthai = Dao.Rows(0)("QUYENCHITIET.Trangthai")
            End If
        Catch ex As Exception
        End Try
        Try
            If IsDBNull(Dao.Rows(0)("Ghichu")) = False Then
                dto.Ghichu = Dao.Rows(0)("Ghichu")
            End If
        Catch ex As Exception
        End Try
        Try
            If IsDBNull(Dao.Rows(0)("QUYENCHITIET.Ghichu")) = False Then
                dto.Ghichu = Dao.Rows(0)("QUYENCHITIET.Ghichu")
            End If
        Catch ex As Exception
        End Try
        Return dto
    End Function
    Public Function LayBangDTo(ByVal i As Integer, ByVal dao As DataTable) As QUYENCHITIETdto
        Dim dto As New QUYENCHITIETdto
        If dao.Rows.Count <= 0 Then Return dto
        Try
            If IsDBNull(dao.Rows(i)("iD")) = False Then
                dto.iD = dao.Rows(i)("iD")
            End If
        Catch ex As Exception
        End Try
        Try
            If IsDBNull(dao.Rows(i)("QUYENCHITIET.iD")) = False Then
                dto.iD = dao.Rows(i)("QUYENCHITIET.iD")
            End If
        Catch ex As Exception
        End Try
        Try
            If IsDBNull(dao.Rows(i)("Quyen")) = False Then
                dto.Quyen = dao.Rows(i)("Quyen")
            End If
        Catch ex As Exception
        End Try
        Try
            If IsDBNull(dao.Rows(i)("QUYENCHITIET.Quyen")) = False Then
                dto.Quyen = dao.Rows(i)("QUYENCHITIET.Quyen")
            End If
        Catch ex As Exception
        End Try
        Try
            If IsDBNull(dao.Rows(i)("TenForm")) = False Then
                dto.TenForm = dao.Rows(i)("TenForm")
            End If
        Catch ex As Exception
        End Try
        Try
            If IsDBNull(dao.Rows(i)("QUYENCHITIET.TenForm")) = False Then
                dto.TenForm = dao.Rows(i)("QUYENCHITIET.TenForm")
            End If
        Catch ex As Exception
        End Try
        Try
            If IsDBNull(dao.Rows(i)("TenButon")) = False Then
                dto.TenButon = dao.Rows(i)("TenButon")
            End If
        Catch ex As Exception
        End Try
        Try
            If IsDBNull(dao.Rows(i)("QUYENCHITIET.TenButon")) = False Then
                dto.TenButon = dao.Rows(i)("QUYENCHITIET.TenButon")
            End If
        Catch ex As Exception
        End Try
        Try
            If IsDBNull(dao.Rows(i)("Trangthai")) = False Then
                dto.Trangthai = dao.Rows(i)("Trangthai")
            End If
        Catch ex As Exception
        End Try
        Try
            If IsDBNull(dao.Rows(i)("QUYENCHITIET.Trangthai")) = False Then
                dto.Trangthai = dao.Rows(i)("QUYENCHITIET.Trangthai")
            End If
        Catch ex As Exception
        End Try
        Try
            If IsDBNull(dao.Rows(i)("Ghichu")) = False Then
                dto.Ghichu = dao.Rows(i)("Ghichu")
            End If
        Catch ex As Exception
        End Try
        Try
            If IsDBNull(dao.Rows(i)("QUYENCHITIET.Ghichu")) = False Then
                dto.Ghichu = dao.Rows(i)("QUYENCHITIET.Ghichu")
            End If
        Catch ex As Exception
        End Try
        Return dto
    End Function
    Public Function LayBangDTo(ByVal dong As Integer, ByVal dao As DataGridView) As QUYENCHITIETdto
        Dim dto As New QUYENCHITIETdto
        If dao.Rows.Count <= 0 Then Return dto
        For cot As Integer = 0 To dao.Columns.Count - 1
            Try
                dto.HoTro(dao.Columns(cot).DataPropertyName, dao.Item(cot, dong).Value)
            Catch ex As Exception
            End Try
        Next
        Return dto
    End Function
    Public Function layBangNhieuTable() As DataTable
        Dim Dao As New QUYENCHITIETDao(ketnoi)
        Dao.layBangNhieuTable()
        Return Dao
    End Function
    Public Sub Taotable()
        Dim Dao As New QUYENCHITIETDao(ketnoi)
        Dao.TaoTable()
    End Sub
#Region "khac"
    Public Function LayBangTableTheoQuyen(ByVal Quyen As System.Int32, ByVal tenform As String) As DataTable
        Dim Dao As New QUYENCHITIETDao(ketnoi)
        Dao.layBangTheoQuyen(Quyen, tenform)
        Return Dao
    End Function
    Public Sub XOA(ByVal maQuyen As Integer, ByVal tenform As String, ByVal TenButon As System.String)
        Dim Dao As New QUYENCHITIETDao(ketnoi)
        Dao.Xoa(maQuyen, tenform, TenButon)
    End Sub
    Public Function KiemTraCo(ByVal Quyen As Integer, ByVal tenForm As String, ByVal Tenbuton As String) As Boolean
        Dim Dao As New QUYENCHITIETDao(ketnoi)
        Return Dao.KiemTraCo(Quyen, tenForm, Tenbuton)
    End Function
    Public Function KiemTraCo(ByVal Quyen As Integer, ByVal tenForm As String) As DataTable
        Dim Dao As New QUYENCHITIETDao(ketnoi)
        Dao.KiemTraCo(Quyen, tenForm)
        Return Dao
    End Function
#End Region
End Class

